package com.ad.platform.api;

import com.ad.payload.dto.JielongTimeZoneDto;
import com.ad.payload.model.IdDto;
import com.ad.payload.model.PageView;
import com.ad.payload.vo.JielongTimeZoneVo;
import com.ad.platform.service.IJielongTimeZoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 接龙时间区段 前端控制器
 * </p>
 *
 * @author rclia
 * @since 2021-04-05
 */
@RestController
@RequestMapping("/JielongTimeZoneApi")
public class JielongTimeZoneApi {

    @Autowired
    private IJielongTimeZoneService iJielongTimeZoneService;

    /**
     * 查询商家接龙时间区段(时间区段之间不允许有交集,可以存在空隙)
     *
     * @param idDto 商家id
     * */
    @PostMapping("/client/noAuth/listTimeZoneByMerchantId")
    public List<JielongTimeZoneVo> listTimeZoneByMerchantId(@RequestBody @Valid IdDto idDto){
        return iJielongTimeZoneService.listTimeZoneByMerchantId(idDto);
    }

    /**
     * 商家接龙时间区段 新增或修改
     *
     * @param jielongTimeZoneDto
     * */
    @PostMapping("/client/noAuth/saveOrUpdate")
    public String saveOrUpdate(@RequestBody @Valid JielongTimeZoneDto jielongTimeZoneDto){
        return iJielongTimeZoneService.saveOrUpdate(jielongTimeZoneDto) ? "成功" : "失败";
    }

    /**
     * 商家接龙时间区段 删除
     *
     * @param idDto 主键id
     * */
    @PostMapping("/client/noAuth/delTimeZone")
    public String delTimeZone(@RequestBody @Valid IdDto idDto){
        return iJielongTimeZoneService.delTimeZone(idDto) ? "成功" : "失败";
    }
}
